"use strict";
cc._RF.push(module, '42305SoAc1Cz7R1TA7p9naq', 'QQBlockAd');
// scripts/QQBlockAd.js

"use strict";

var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {
  value: !0
});
n.BlockNum = n.Orientation = void 0;
var o,
    i,
    a = cc._decorator,
    r = a.ccclass,
    s = a.property;

(function (e) {
  e[e["横向"] = 0] = "横向";
  e[e["竖向"] = 1] = "竖向";
})(o = n.Orientation || (n.Orientation = {}));

(function (e) {
  e[e[" 1 "] = 1] = " 1 ";
  e[e[" 2 "] = 2] = " 2 ";
  e[e[" 3 "] = 3] = " 3 ";
  e[e[" 4 "] = 4] = " 4 ";
  e[e[" 5 "] = 5] = " 5 ";
})(i = n.BlockNum || (n.BlockNum = {}));

var c = function (e) {
  __extends(t, e);

  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.orientation = o.横向;
    t.blockNum = i[" 5 "];
    t.qqBlockAd = null;
    t._orientation = ["landscape", "vertical"];
    return t;
  }

  t.prototype.onEnable = function () {
    SDK.Mgr.Inst.curChannel == SDK.Define.Channel.qq && this.qqBlockAd && this.qqBlockAd.show();
  };

  t.prototype.onDisable = function () {
    SDK.Mgr.Inst.curChannel == SDK.Define.Channel.qq && this.qqBlockAd && this.qqBlockAd.hide();
  };

  t.prototype.start = function () {
    var e = this;
    this.scheduleOnce(function () {
      e.createAd();
    }, .1);
  };

  t.prototype.createAd = function () {
    var e = this;

    if (SDK.Mgr.Inst.curChannel == SDK.Define.Channel.qq) {
      var t = qq.getSystemInfoSync(),
          n = this.node.parent.convertToWorldSpaceAR(this.node.getPosition()),
          o = n.x / cc.view.getDesignResolutionSize().width * t.screenWidth,
          i = (1 - n.y / cc.view.getDesignResolutionSize().height) * t.screenHeight;
      cc.Canvas.instance.fitHeight ? o = n.x / (cc.view.getDesignResolutionSize().height / t.screenHeight * t.screenWidth) * t.screenWidth : i = (1 - n.y / (cc.view.getDesignResolutionSize().width / t.screenWidth * t.screenHeight)) * t.screenHeight;
      this.qqBlockAd = qq.createBlockAd({
        adUnitId: Config.QQ.blockId,
        style: {
          left: o,
          top: i
        },
        size: this.blockNum,
        orientation: this._orientation[this.orientation]
      });
      setTimeout(function () {
        e.qqBlockAd.show();
      }, 500);
      this.qqBlockAd.onError(function (e) {
        console.log("onError", JSON.stringify(e));
      });
      this.qqBlockAd.onResize(function (e) {
        console.log("onResize", JSON.stringify(e));
      });
    }
  };

  t.prototype.onDestroy = function () {
    SDK.Mgr.Inst.curChannel == SDK.Define.Channel.qq && this.qqBlockAd && this.qqBlockAd.destroy();
  };

  __decorate([s({
    type: cc.Enum(o),
    displayName: "排列方向"
  })], t.prototype, "orientation", void 0);

  __decorate([s({
    type: cc.Enum(i),
    displayName: "积木数量"
  })], t.prototype, "blockNum", void 0);

  return __decorate([r], t);
}(cc.Component);

n["default"] = c;

cc._RF.pop();